package com.myway.dto.rule.domain;

import java.util.HashMap;

/**
 * 类名称：SupportBaseRuleType 类描述：辅营订单状态 创建时间：2016-3-18
 * 类描述：辅营订单状态
 * @author hongjun
 * @version V1.0
 */
public enum SupportBaseRuleType {
	
	VC("VC"), // 自愿变更
	VR("VR"), // 自愿退票
	
	CB72H("1"), 	//自愿变更（72小时[含]以上）
	CB72T12H("2"), 	//自愿变更（72~12小时[含]以上）
	CA12H("3"),  	//自愿变更（12小时以后）
	
	RB72H("1"), 	//自愿退票（72小时[含]以上）
	RB72T12H("2"),  //自愿退票（72~12小时[含]以上）
	RA12H("3");  	//自愿退票（12小时以后）
	
	
	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, SupportBaseRuleType> map;

	/**
	 * Construct the hash map at load time
	 */
	static {
		map = new HashMap<String, SupportBaseRuleType>();
		for (SupportBaseRuleType type : SupportBaseRuleType.values()) {
			map.put(type.alias, type);
		}
	}

	SupportBaseRuleType(String alias) {
		this.alias = alias;
	}

	@Override
	public String toString() {
		return this.alias;

	}

	/**
	 * Return a <code>Action</code> object holding the value of specified alias  name
	 * @param alias  the alias name of the type
	 * @return a <code>Action</code> object holding the value represented by the alias name argument
	 */
	public static SupportBaseRuleType valueOfAlias(String alias) {
		SupportBaseRuleType type = map.get(alias);

		if (type == null) {
			throw new IllegalArgumentException("Unknown action alias [" + alias + "]");
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias() {
		return this.alias;
	}

}
